/*     */ package com.yss.sofa.cml;
/*     */ 
/*     */ import java.lang.reflect.Field;
/*     */ import javax.print.attribute.standard.MediaSize;
/*     */ import javax.print.attribute.standard.MediaSize.ISO;
/*     */ import javax.print.attribute.standard.MediaSizeName;
/*     */ 
/*     */ public class Paper
/*     */   implements SerializableObject
/*     */ {
/*     */   private static final long serialVersionUID = 1L;
/*     */ 
/*     */   @Deprecated
/*  20 */   public static final Paper A4 = getPaper(MediaSize.ISO.A4);
/*     */ 
/*  22 */   public static final Paper ISO_A4 = getPaper(MediaSize.ISO.A4);
/*     */ 
/*  27 */   public static final Paper PRC_16K = getPaper("16K", 185.0F, 260.0F);
/*     */   protected float height;
/*     */   protected float width;
/*     */   protected String name;
/*     */ 
/*     */   public Paper(MediaSize mediaSize)
/*     */   {
/*  34 */     this(mediaSize.getMediaSizeName().toString(), mediaSize.getSize(1000)[0], mediaSize.getSize(1000)[1]);
/*     */   }
/*     */ 
/*     */   public Paper(String name, float width, float height)
/*     */   {
/*  39 */     this.name = name;
/*  40 */     this.width = width;
/*  41 */     this.height = height;
/*     */   }
/*     */ 
/*     */   public static Paper getPaper(MediaSize mediaSize)
/*     */   {
/*  50 */     return new Paper(mediaSize);
/*     */   }
/*     */ 
/*     */   public static Paper getPaper(String paperName, float width, float height)
/*     */   {
/*  61 */     return new Paper(paperName, width, height);
/*     */   }
/*     */ 
/*     */   public static Paper findPaper(String paperName)
/*     */   {
/*  70 */     Field[] fields = MediaSizeName.class.getDeclaredFields();
/*  71 */     for (int i = 0; i < fields.length; i++) {
/*  72 */       Field field = fields[i];
/*  73 */       if (field.getType().isAssignableFrom(MediaSizeName.class)) {
/*  74 */         field.setAccessible(true);
/*     */         try {
/*  76 */           Object msn = field.get(null);
/*  77 */           String value = String.valueOf(msn);
/*  78 */           if (value.equalsIgnoreCase(paperName))
/*  79 */             return new Paper(MediaSize.getMediaSizeForName((MediaSizeName)msn));
/*     */         }
/*     */         catch (Exception e) {
/*     */         }
/*     */       }
/*     */     }
/*  85 */     return null;
/*     */   }
/*     */ 
/*     */   public String getName()
/*     */   {
/*  93 */     return this.name;
/*     */   }
/*     */ 
/*     */   public float getWidth()
/*     */   {
/* 101 */     return this.width;
/*     */   }
/*     */ 
/*     */   public float getHeight()
/*     */   {
/* 109 */     return this.height;
/*     */   }
/*     */ 
/*     */   public String toString() {
/* 113 */     return this.name;
/*     */   }
/*     */ }

/* Location:           X:\repository\com\yss\sofa\cml\cml-api\1.1.0\cml-api-1.1.0.jar
 * Qualified Name:     com.yss.sofa.cml.Paper
 * JD-Core Version:    0.6.0
 */